package com.gl.rent;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.HouseRecord;
import com.haixiaoke.saas.repository.service.IHouseRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 房屋上下架记录Controller
 * 
 * @author haixiaoke
 * @date 2023-04-11
 */
@RestController
@RequestMapping("/base/houseRecord")
public class HouseRecordController extends BaseController {
    @Autowired
    private IHouseRecordService houseRecordService;

    /**
     * 查询房屋上下架记录列表
     */
    @PreAuthorize("@ss.hasPermi('saas-repository:houseRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseRecord houseRecord) {
        startPage();
        List<HouseRecord> list = houseRecordService.selectHouseRecordList(houseRecord);
        return getDataTable(list);
    }

    /**
     * 获取房屋上下架记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('saas-repository:houseRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(houseRecordService.selectHouseRecordById(id));
    }

    /**
     * 新增房屋上下架记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:houseRecord:add')")
//    @Log(title = "房屋上下架记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseRecord houseRecord) {
        return toAjax(houseRecordService.insertHouseRecord(houseRecord));
    }

    /**
     * 修改房屋上下架记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:houseRecord:edit')")
//    @Log(title = "房屋上下架记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseRecord houseRecord) {
        return toAjax(houseRecordService.updateHouseRecord(houseRecord));
    }

    /**
     * 删除房屋上下架记录
     */
//    @PreAuthorize("@ss.hasPermi('saas-repository:houseRecord:remove')")
//    @Log(title = "房屋上下架记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(houseRecordService.deleteHouseRecordByIds(ids));
    }
}
